# -*- coding:utf-8 -*-
"""
Author：Administrator
Date:2021年10月15日
"""
from docx import Document
from docx.shared import Cm, Inches

import docx

doc = docx.Document()
doc.add_heading('Name: ', level=1)

table = doc.add_table(rows=3, cols=9, style='Table Grid')
# col_width_dic = {0: 0.5, 1: 2, 2: 0.5, 3: 1, 4: 1, 5: 1, 6: 2}
# table.columns[1].width = Cm(3)
# for col_num in range(7):
# 	table.cell(0, col_num).width = Cm(col_width_dic[col_num])
widths = (Cm(5.5), Cm(2), Cm(1.3), Cm(1.3), Cm(1.3), Cm(1.3), Cm(1.3), Cm(1.6), Cm(2.5))
for row in table.rows:
	for idx, width in enumerate(widths):
		row.cells[idx].width = width

# for i in range(len(table.columns)):
# 	print(table.columns[i])
		# for cell in table.columns[i+1]:
		# 	cell.width = Cm(1)

doc.save('test.docx')
